Repository navigation
Conversation
Pull request dashboard statusWaiting on the author · refreshed 2026-12-04 22:34 UTC Respond to 4 review items (e.g. link a commit, explain why not, ask a follow-up): Status above doesn't look right?
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9060 +/- ##
============================================
- Coverage 90.56% 90.52% -0.04%
- Complexity 11220 11265 +45
============================================
Files 1032 1040 +8
Lines 30599 30766 +167
Branches 4010 4021 +11
============================================
+ Hits 27711 27851 +140
- Misses 1913 1934 +21
- Partials 975 981 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Update autoconfigure and declarative configuration to attach a shared SdkResourceProvider to SdkTracerProvider, SdkMeterProvider, and SdkLoggerProvider instead of a static Resource. - In declarative config, use Sdk*ProviderUtil.setSdkResourceProvider to attach the provider built from the resolved resource model. - In autoconfigure, introduce and use setDefaultSdkResourceProvider on the signal provider builders to set the baseline resource provider while allowing signal-specific customizers to override or merge resources via setResource or addResource without throwing IllegalStateException. - Preserve fail-fast guards when setSdkResourceProvider and setResource/addResource are explicitly configured on the same builder. - Add unit tests verifying default provider usage, customizer overrides, and cross-signal provider sharing.
a01ffca to
e5d48e7
Compare
jack-berg
left a comment
There was a problem hiding this comment.
Thanks for working on this - i've been meaning to do this.
| } | ||
| this.resource = this.resource.merge(resource); | ||
| this.resourceExplicitlySet = true; | ||
| Resource current = resourceProvider != null ? resourceProvider.getResource() : this.resource; | ||
| this.resource = current.merge(resource); | ||
| this.resourceProvider = null; | ||
| this.resourceSource = ResourceSource.EXPLICIT_RESOURCE; |
There was a problem hiding this comment.
A tracer customizer calling addResource(Resource.empty()) replaces the shared SdkResourceProvider with a separate provider despite leaving the resource unchanged. setResource() with an equivalent resource does the same. ExtendedOpenTelemetrySdk.getSdkResourceProvider() still succeeds because its resolver compares the providers' resources with .equals(). If that resolver required provider instance equality, it would throw despite no resource change.
I think we should preserve the shared provider instance when the final customized resource is equivalent to the configured resource, with integration tests asserting shared provider identity across all three signals.
| SdkTracerProviderBuilder setDefaultSdkResourceProvider(SdkResourceProvider resourceProvider) { | ||
| requireNonNull(resourceProvider, "resourceProvider"); | ||
| if (resourceSource == ResourceSource.UNSET | ||
| || resourceSource == ResourceSource.DEFAULT_PROVIDER) { | ||
| this.resourceProvider = resourceProvider; | ||
| this.resourceSource = ResourceSource.DEFAULT_PROVIDER; | ||
| } | ||
| return this; |
There was a problem hiding this comment.
This puts autoconfigure policy into the SDK builders. All three gain default-vs-explicit provider semantics and four-state bookkeeping to accommodate autoconfigure's customizer lifecycle.
I think we should keep the decision about shared provider attachment in autoconfigure, after customizers run, rather than introducing a second provider-setting mode in each SDK builder. This would require using reflection against the provider builder's internal resource tracking fields.
| Resource resource, | ||
| SpiHelper spiHelper, | ||
| List<Closeable> closeables) { | ||
| SdkResourceProvider resourceProvider = SdkResourceProvider.create(resource); |
There was a problem hiding this comment.
Could resource configuration build the SdkResourceProvider from individually named resource contributions instead of wrapping the final merged resource? This collapses the default resource and all detector results into one unnamed constant, losing their source structure. The declarative path does the same. Preserving those contributions would provide the foundation for per-detector refresh later, while retaining existing merge, filtering, and customization behavior.
|
|
||
| SdkTracerProviderBuilder tracerProviderBuilder = SdkTracerProvider.builder(); | ||
| tracerProviderBuilder.setResource(resource); | ||
| SdkTracerProviderUtil.setDefaultSdkResourceProvider(tracerProviderBuilder, resourceProvider); |
There was a problem hiding this comment.
Please update the tracer, meter, and logger provider-customizer Javadocs to recommend addResourceCustomizer() instead of calling setResource() or addResource() on individual signal builders. Explain that provider-level resource customization can opt that signal out of the shared SDK resource provider, and that setResource() also replaces detected resources and resource-customizer results. The concrete builder methods should inherit or include this guidance so it is visible from either API.
Description
Implements follow-up 1 from #8865 by attaching
SdkResourceProvidertoSdkMeterProvider,SdkLoggerProvider, andSdkTracerProviderinstead of a staticResource.Changes
SdkResourceProviderviaSdk*ProviderUtil.setSdkResourceProvider(...)across all signal builders.setDefaultSdkResourceProvidertoSdkTracerProviderBuilder,SdkMeterProviderBuilder, andSdkLoggerProviderBuilder. Autoconfigure supplies the baseline provider without tripping the strictIllegalStateExceptionguard if a user customizer subsequently overrides or merges resources via.setResource(...)or.addResource(...).setSdkResourceProvidercontinue to fail-fast against conflictingsetResource/addResourceinvocations.